package cn.kgc.javaweb.servlet;

import cn.kgc.javaweb.service.StudentService;
import cn.kgc.javaweb.service.impl.StudentServiceImpl;
import cn.kgc.javaweb.utils.JSONResult;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/5/15
 * @Description:
 * localhost:8080/student?method=add
 * localhost:8080/student?method=delete
 */
@WebServlet("/student")
public class StudentServlet extends BaseServlet {

    private StudentService studentService = new StudentServiceImpl();

    //学生信息分页接口
    protected void studentPage(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 获取请求参数
        Integer page = Integer.valueOf(req.getParameter("page"));
        Integer limit = Integer.valueOf(req.getParameter("limit"));
        String studentName = req.getParameter("studentName");
        String clazz = req.getParameter("clazz");

        HashMap<String,Object>  map = studentService.getPage(page,limit,studentName,clazz);
        JSONResult.writeJson(map,resp);

    }

}
